﻿using dsf.scenery.order.finance.MongoHelper;
using MongoDB.Driver;
using QuestionInvestig.Model;
using QuestionInvestig.MongoHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QuestionInvestig.Business
{
    public class QuestionService
    {


        public static QuestionAnswerModelList GetQuestionTitle(string title)
        {
            QuestionAnswerModelList List = new QuestionAnswerModelList();
            
            Mongo mongoClick = new Mongo();
            var builder = Builders<QuestionAnswerModel>.Filter;
            var filter = builder.Eq(t => t.IsValid, 1);
            if (!string.IsNullOrEmpty(title))
            {
                filter = filter & builder.Eq(t => t.QuesTitle, title);
            }
            var sort = Builders<QuestionAnswerModel>.Sort.Ascending("_id");
            List<QuestionAnswerModel> list = mongoClick.Find(MongoDbManager.QuestionConfiguration, filter, sort);
            long count = mongoClick.FindCount(MongoDbManager.QuestionConfiguration, filter);
            List.List = list;
            return List;
        }
    }
}
